﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using CoreModel = PlayerScannerCore.Model;
using Mvvm;
using PlayerScannerCore.Model;

namespace PlayerScannerCore.ViewModel
{
    public class TechDiskViewModel : ItemViewModel, ITechDisk
    {
        private int _level;

        internal TechDiskViewModel()
        {
            ItemType = ItemType.TechDisk;
        }
            
        internal override void Update(IItem item)
        {
            var techDisk = (ITechDisk)item;
            
            Level = techDisk.Level;

            base.Update(techDisk);
        }

        public int Level
        {
            get { return _level; }
            set
            {
                if (_level != value)
                {
                    _level = value;
                    OnPropertyChanged("Level");
                }
            }
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int hash = 23;
                hash = hash * 29 + Level.GetHashCode();
                return hash * 29 + base.GetHashCode();
            }
        }

        public override bool Equals(object obj)
        {
            var objAsSpecific = obj as TechDiskViewModel;

            if (objAsSpecific == null)
                return false;

            if (ReferenceEquals(this, obj))
                return true;

            return objAsSpecific.Level == Level
                && base.Equals(obj);
        }
    }
}
